<template>
    <div style="height: 100px; width: 100%; background: aqua;">
      <div @click="$router.push({path:'/a'})">这是组件AAAA</div>
      <div>我的名字：{{resturantName}},我的年龄：{{resturantAge}}</div>
      <div>修改我的名字：</div>
      <input type="text" @input="chag" v-model="name" :placeholder="resturantName" />
      <input type="text" @input="chae" v-model="age" :placeholder="resturantAge" />
    </div>
</template>

<script>
  import {mapActions, mapGetters} from 'vuex'

  export default {
        name: "coma",
        data () {
          return{
            name:'',
            age:''
          }
        },
        methods:{
          ...mapActions(
            ['modifyAName','modifyAAge'] // 相当于this.$store.dispatch('modifyName'),提交这个方法
          ),
          chag () {
            this.modifyAName(this.name)
          },
          chae () {
            this.modifyAAge(this.age)
          }
        },
        computed: {
          ...mapGetters(['resturantName','resturantAge']) // 动态计算属性，相当于this.$store.getters.resturantName
        },
        created() {
          // alert(this.resturantName)
        }
  }
</script>

<style scoped>

</style>
